
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 0143
 * @Author : WangRuoyu 
 * @Date : 2023/9/20 15:20
 */

#include "iostream"

const int N = 1e5 + 10;
const int M = 31 * N;
int son[M][2];
int idx = 0;

using namespace std;

void insert(int x) {
    int p = 0;
    for (int i = 30; i >= 0; --i) {
        int u = x >> i & 1;
        if (!son[p][u]) son[p][u] = ++idx;
        p = son[p][u];
    }
}

int query(int x) {
    int p = 0, res = 0;
    for (int i = 30; i >= 0; --i) {
        int u = x >> i & 1;
        if (son[p][1 - u]) {
            res = res * 2 + 1 - u;
            p = son[p][1 - u];
        } else {
            res = res * 2 + u;
            p = son[p][u];
        }
    }
    return res ^ x;
}

int main() {
    int n;
    scanf("%d", &n);
    int res = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        insert(x);
        res = max(res, query(x));
    }
    printf("%d", res);
    return 0;
}